<!--
 * @Description: 结算详情页面
 * @Autor: 何兴家
 * @Date: 2021-01-04 13:21:06
 * @LastEditors: 何兴家
 * @LastEditTime: 2021-03-26 16:48:31
-->
<template>
  <div v-loading="pageIsLoading">
    <!-- 顶部按钮区 -->
    <div class="topBtnsWrap">
      <ButtonArea :style="{ paddingLeft: '0px', paddingRight: '0px' }">
        <el-button :disabled="btnDisabledStatus" type="primary" @click="handleSubObbBtnClick">去零</el-button>
        <AjaxButton :disabled="btnDisabledStatus" type="primary" :click="handleBallanceClick">结算</AjaxButton>
        <printBallanceOrder v-if="orderType == 'repair'" :disabled="btnDisabledStatus && hasBallanceNo" printType="pre" :defaultData="prePrintData" btnText="预打印" :roNo="roNo" />
        <printBallanceOrder v-if="orderType == 'repair'" :disabled="!btnDisabledStatus || !hasBallanceNo" btnText="打印" :roNo="roNo" />
        <el-button type="primary" @click="handleCancel">取消</el-button>
      </ButtonArea>
      <ButtonArea :style="{ paddingLeft: '0px', paddingRight: '0px' }">
        <el-button icon="el-icon-close" style="position: relative;right: -10px" @click="handleCancel">关闭</el-button>
      </ButtonArea>
    </div>

    <!-- 工单信息 -->
    <div class="box" v-if="orderType == 'repair'">
      <BreakSpace label="工单信息" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
      <FormPanel ref="orderInfoForm" :list="orderInfoFormList" :cols="4" :labelWidth="100" :isSubmitBtn="false"></FormPanel>
    </div>

    <!-- 车主车辆信息 -->
    <div class="box" v-if="orderType == 'repair'">
      <BreakSpace label="车主车辆信息" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
      <FormPanel ref="carOwnerForm" :list="carOwnerFormList" :cols="4" :labelWidth="100" :isSubmitBtn="false"></FormPanel>
    </div>

    <!-- 配件销售单信息 -->
    <div class="box" v-if="orderType == 'part'">
      <BreakSpace label="配件销售单信息" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
      <FormPanel ref="partSaleForm" :list="partSaleFormList" :cols="4" :labelWidth="100" :isSubmitBtn="false"></FormPanel>
    </div>

    <!-- 结算单信息 -->
    <div class="box">
      <BreakSpace label="结算单信息" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
      <FormPanel ref="balanceForm" :list="ballanceFormList" :cols="4" :labelWidth="100" :isSubmitBtn="false"></FormPanel>
    </div>

    <!-- 维修配件项目详情及金额计算框 -->
    <div class="detailWrap">
      <div class="left">
        <el-tabs v-model="activeDetailTab">
          <el-tab-pane label="维修项目" name="维修项目" v-if="orderType == 'repair'">
            <FilterTable
              ref="repairLabourTable"
              columnsRef="repair_repairReception_feesettlement_balanceDetail_labour"
              height="auto"
              :columns="repairLabourColumns"
              :dataSource="repairLabourTableDataSource"
              :onSyncTableData="handleSyncRepairLabourTableData"
              :onRowSelectChange="handleRepairLabourTableSelect"
              :onColumnsChange="columns => (this.repairLabourColumns = columns)"
            >
            </FilterTable>
          </el-tab-pane>
          <el-tab-pane label="维修材料" name="维修材料" v-if="orderType == 'repair'">
            <FilterTable
              ref="repairPartTable"
              columnsRef="repair_repairReception_feesettlement_balanceDetail_part"
              height="auto"
              :columns="repairPartColumns"
              :dataSource="repairPartTableDataSource"
              :onSyncTableData="handleSyncRepairPartTableData"
              :onRowSelectChange="handleRepairPartTableSelect"
              :onColumnsChange="columns => (this.repairPartColumns = columns)"
            >
            </FilterTable>
          </el-tab-pane>
          <el-tab-pane label="附加项目" name="附加项目" v-if="orderType == 'repair'">
            <FilterTable
              ref="additionItemTable"
              columnsRef="repair_repairReception_feesettlement_balanceDetail_additionItem"
              height="auto"
              :columns="additionItemColumns"
              :dataSource="additionItemTableDataSource"
              :onSyncTableData="handleSyncAdditionItemTableData"
              :onRowSelectChange="handleAdditionItemTableSelect"
              :onColumnsChange="columns => (this.additionItemColumns = columns)"
            >
            </FilterTable>
          </el-tab-pane>
          <el-tab-pane label="销售材料" name="销售材料" v-if="orderType == 'part'">
            <FilterTable
              ref="salesPartTable"
              columnsRef="repair_repairReception_feesettlement_balanceDetail_salesPart"
              height="auto"
              :columns="salesPartColumns"
              :dataSource="salesPartTableDataSource"
              :onSyncTableData="handleSyncSalesPartTableData"
              :onRowSelectChange="handleSalesPartTableSelect"
              :onColumnsChange="columns => (this.salesPartColumns = columns)"
            >
            </FilterTable>
          </el-tab-pane>
        </el-tabs>
        <!-- 折扣率 -->
        <FormPanel ref="discountForm" :list="discountFormList" :cols="4" :labelWidth="90" :isSubmitBtn="false"></FormPanel>
        <!-- 优惠券 -->
        <BreakSpace v-show="false" label="优惠金额" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
        <FilterTable
          v-show="false"
          ref="discountCouponTable"
          columnsRef="repair_repairReception_feesettlement_balanceDetail_discountCoupon"
          height="auto"
          :columns="discountCouponColumns"
          :dataSource="discountCouponTableDataSource"
          :onSyncTableData="handleSyncDiscountCouponTableData"
          :onRowSelectChange="handleDiscountCouponTableSelect"
          :onColumnsChange="columns => (this.discountCouponColumns = columns)"
        >
          <template slot="controls">
            <el-button type="primary" :disabled="btnDisabledStatus">新增优惠</el-button>
          </template>
        </FilterTable>
        <!-- 应收实收收费对象 -->
        <el-tabs v-model="activeReceiveTabs">
          <el-tab-pane name="应收" label="应收">
            <FilterTable
              ref="receivableTable"
              columnsRef="repair_repairReception_feesettlement_balanceDetail_receivable"
              height="auto"
              :isSelectColumn="false"
              :columns="receivableColumns"
              :dataSource="receivableTableDataSource"
              :onSyncTableData="handleSyncReceivableTableData"
              :onColumnsChange="columns => (this.receivableColumns = columns)"
            >
            </FilterTable>
          </el-tab-pane>
          <el-tab-pane name="实收" label="实收">
            <FilterTable
              ref="realIncomeTable"
              columnsRef="repair_repairReception_feesettlement_balanceDetail_realIncome"
              height="auto"
              :columns="realIncomeColumns"
              :dataSource="realIncomeTableDataSource"
              :onSyncTableData="handleSyncRealIncomeTableData"
              :onRowSelectChange="handleRealIncomeTableSelect"
              :onColumnsChange="columns => (this.realIncomeColumns = columns)"
            >
              <template slot="controls">
                <!-- <el-button type="primary">新增收费对象</el-button> -->
              </template>
            </FilterTable>
          </el-tab-pane>
        </el-tabs>
      </div>
      <div class="right">
        <BreakSpace label="费用信息" :containerStyle="{ marginBottom: '10px' }"></BreakSpace>
        <FormPanel ref="costInfoForm" :list="costInfoFormList" :cols="1" :labelWidth="90" :isSubmitBtn="false"></FormPanel>
      </div>
    </div>

    <!-- 去零金额弹窗 -->
    <BaseDialog :visible.sync="showSubObbPanel" title="去零" width="400px" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <subObbPanel :limit="repairParams[1029]" :costInfoObj="costInfoObj" @close="showSubObbPanel = false" @onConfirm="handleSubObbPanelConfimr" />
    </BaseDialog>
  </div>
</template>

<script>
import _ from 'lodash';
import { dictionary } from '@/utils/dictMixin';
import { confirmAction, notifyAction, findFormItem, findTableItem, setRound, jsonToHump } from '@/utils';
import { createOrderInfoList, createCarOwnerFormList, createPartSaleFormList, createBallanceFormList, createCostInfoFormList, createDiscountFormList } from './formStatement.js';
import {
  createRepairLabourColumns,
  createRepairPartColumns,
  createAdditionItemColumns,
  createSalesPartColumns,
  createDiscountCouponColumns,
  createReceivableColumns,
  createRealIncomeColumns
} from './tableStatement.js';

import subObbPanel from './subObbPanel';
import printBallanceOrder from './printBallanceOrder';

import { searchRepairOrderDetail, queryUserControlDiscountMode1, saveBalanceAccounts, searchPartRepairOrderDetail } from '@/api/repair/repairReception/feesSettlement';
import { getWxlxSelect, getSfqfSelect } from '@/api/repair/repairReception/customer';
import { getSystemDefault, getDealerUser } from '@/api/repair/common';

export default {
  props: ['orderDetail', 'defaultPageType', 'defaultOrderType', 'repairParams'],
  mixins: [dictionary],
  components: {
    subObbPanel,
    printBallanceOrder
  },
  data() {
    this.selectedRepairLabourList = []; // 选中的维修项目列表
    this.selectedRepairPartList = []; // 选中的维修配件列表
    this.selectedAdditionItemList = []; // 选中的附加项目列表
    this.selectedSalesPartList = []; // 选中的销售配件行项
    this.selectedDiscountCouponList = []; // 选中的优惠券行项
    this.selectedRealIncomeList = []; // 选中的实收收费对象行项
    this.tax = 0.13; // 税率
    this.orderInfo = {}; // 储存查询回来的工单信息
    this.rechargeableCodes = ['B', 'Z']; // 需要收钱的收费区分（保险，自费）
    this.oemChargeCode = ['S']; // 厂端收费对象收费区分code
    this.ownerChargeCode = ['Z']; // 车主收费对象收费区分code
    this.oemChargeObj = { PAYMENT_OBJECT_CODE: '999999999999', PAYMENT_OBJECT_NAME: 'OEM主机厂' };
    this.dealerChargeObj = { PAYMENT_OBJECT_CODE: '888888888888', PAYMENT_OBJECT_NAME: '4S站' };
    this.sfqfDict = []; // 收费区分字典项
    this.discourtHistoryList = [1, 1, 1, 1]; // 折扣历史储存
    this.discountModeList = []; // 权限优惠模式列表
    this.discountLimt = {
      // 最低折扣权限
      ADDITIONAL_ITEMS_DISCOUNT: 1,
      LABOUR_AMOUNT_DISCOUNT: 1,
      REPAIR_PART_DISCOUNT: 1,
      SALES_PART_DISCOUNT: 1
    };

    return {
      activeDetailTab: '维修项目', // 激活的详情tab
      activeReceiveTabs: '应收', // 激活的应收实收搜tab

      // 表单声明
      orderInfoFormList: createOrderInfoList.call(this),
      carOwnerFormList: createCarOwnerFormList.call(this),
      partSaleFormList: createPartSaleFormList.call(this),
      ballanceFormList: createBallanceFormList.call(this),
      discountFormList: createDiscountFormList.call(this),
      costInfoFormList: createCostInfoFormList.call(this),

      // 表格声明
      repairLabourColumns: createRepairLabourColumns.call(this),
      repairPartColumns: createRepairPartColumns.call(this),
      additionItemColumns: createAdditionItemColumns.call(this),
      salesPartColumns: createSalesPartColumns.call(this),
      discountCouponColumns: createDiscountCouponColumns.call(this),
      receivableColumns: createReceivableColumns.call(this),
      realIncomeColumns: createRealIncomeColumns.call(this),

      // 弹窗
      showSubObbPanel: false,

      // 页面数据
      orderType: 'repair', // 单据类型 repair --维修工单 part --配件销售单
      pageType: 'edit', // 页面类型 edit --编辑/结算 detail --详情展示
      pageIsLoading: false, // 页面加载状态

      repairLabourTableDataSource: [], // 维修项目table数据源
      repairPartTableDataSource: [], // 维修配件table数据源
      additionItemTableDataSource: [], // 附加项目table数据源
      salesPartTableDataSource: [], // 配件销售table数据源
      discountCouponTableDataSource: [], // 优惠券table数据源
      receivableTableDataSource: [], // 应收table数据源
      realIncomeTableDataSource: [], // 实收table数据源

      syncRepairLabourTableDataList: [], // 同步的维修项目table数据
      syncRepairPartTableDataList: [], // 同步的维修配件table数据
      syncAdditionItemTableDataList: [], // 同步的附加项目table数据
      syncSalesPartTableDataList: [], // 同步的配件销售table数据
      syncDiscountCouponTableDataList: [], // 同步的优惠券table数据
      syncReceivableTableDataList: [], // 同步的应收table数据
      syncRealIncomeTableDataList: [] // 同步的实收table数据
    };
  },
  computed: {
    // 费用信息对象
    costInfoObj() {
      let obj = {};
      this.costInfoFormList.forEach(item => {
        obj[item.fieldName] = item.initialValue;
      });
      return obj;
    },
    // 按钮禁用状态
    btnDisabledStatus() {
      return this.pageType == 'detail';
    },
    // 是否有结算单号
    hasBallanceNo() {
      return !!findFormItem(this.ballanceFormList, 'BALANCE_NO').initialValue;
    },
    // 结算单号
    roNo() {
      return findFormItem(this.orderInfoFormList, 'RO_NO').initialValue;
    },
    // 预打印打印数据
    prePrintData() {
      return {
        labourList: this.syncRepairLabourTableDataList,
        partList: this.syncRepairPartTableDataList,
        realList: this.syncRealIncomeTableDataList,
        TOTAL_DISCOUNT_AMOUNT: findFormItem(this.costInfoFormList, 'discountAmount').initialValue,
        RECEIVE_AMOUNT: findFormItem(this.costInfoFormList, 'calcReceiveAmount').initialValue,
        arrBalance: findFormItem(this.costInfoFormList, 'arrBalance').initialValue,
        cahrgePartitionDicts: this.sfqfDict
      };
    }
  },
  watch: {
    // 监听页面类型改变页面字段禁用状态
    pageType(newVal, oldVal) {
      console.log(newVal, 'hexj001');
      if (newVal == 'detail') {
        this.orderInfoFormList.forEach(item => {
          item.disabled = true;
        });
        this.ballanceFormList.forEach(item => {
          item.disabled = true;
        });
        this.discountFormList.forEach(item => {
          item.disabled = true;
        });
        this.costInfoFormList.forEach(item => {
          item.disabled = true;
        });
      }
    },
    // 监听激活的tab页重新赋值优惠率默认值
    activeDetailTab(newVal, oldVal) {
      this.handleDetailTabChange(newVal);
    }
  },
  mounted() {
    this.initPageDicts();
    this.orderType = this.defaultOrderType;
    this.pageType = this.defaultPageType;
    if (this.defaultOrderType == 'repair') {
      this.queryOrderDataByRoNo(this.orderDetail.RO_NO);
      this.queryDiscountModelByRoNo(this.orderDetail.RO_NO);
    } else {
      this.activeDetailTab = '销售材料';
      console.log(this.orderDetail, 'hexj001');
      this.querySalesPartOrderDataBySalesPartNo(this.orderDetail.SALES_PART_NO);
      this.queryDiscountModelByRoNo();
    }
  },
  methods: {
    /**
     * table事件
     */
    // 同步维修项目table数据
    handleSyncRepairLabourTableData(list) {
      this.syncRepairLabourTableDataList = list;
    },
    // 同步维修配件table数据
    handleSyncRepairPartTableData(list) {
      this.syncRepairPartTableDataList = list;
    },
    // 同步附加项目table数据
    handleSyncAdditionItemTableData(list) {
      this.syncAdditionItemTableDataList = list;
    },
    // 同步配件销售table数据
    handleSyncSalesPartTableData(list) {
      this.syncSalesPartTableDataList = list;
    },
    // 同步优惠券table数据
    handleSyncDiscountCouponTableData(list) {
      this.syncDiscountCouponTableDataList = list;
    },
    // 同步应收table数据
    handleSyncReceivableTableData(list) {
      this.syncReceivableTableDataList = list;
    },
    // 同步实收table数据
    handleSyncRealIncomeTableData(list) {
      this.syncRealIncomeTableDataList = list;
    },

    // 维修项目行项选择变化
    handleRepairLabourTableSelect(list) {
      this.selectedRepairLabourList = list;
    },
    // 维修配件行项选择变化
    handleRepairPartTableSelect(list) {
      this.selectedRepairPartList = list;
    },
    // 附加项目行项选择变化
    handleAdditionItemTableSelect(list) {
      this.selectedAdditionItemList = list;
    },
    // 销售配件行项选择变化
    handleSalesPartTableSelect(list) {
      this.selectedSalesPartList = list;
    },
    // 优惠券行项选择变化
    handleDiscountCouponTableSelect(list) {
      this.selectedDiscountCouponList = list;
    },
    // 实收行项选择变化
    handleRealIncomeTableSelect(list) {
      this.selectedRealIncomeList = list;
    },

    /**
     * 初始化查询，字典项等
     */
    initPageDicts() {
      this.queryRepairTypeDict();
      this.querySfqfDict();
      this.queryDealerUser();
      this.initDefaultParams();
    },
    // 根据服务参数初始化部分数据
    initDefaultParams() {
      // 税率
      if (this.repairParams[1003]) {
        this.tax = this.repairParams[1003];
        findFormItem(this.costInfoFormList, 'tax').initialValue = this.repairParams[1003];
      } else {
        this.queryTaxRate();
      }
      // 默认付款方式
      findFormItem(this.costInfoFormList, 'payTypeCode').initialValue = this.repairParams[1121] || '';
    },
    // 获取维修类型
    async queryRepairTypeDict() {
      let res = await getWxlxSelect();
      if (res.resultCode == 200) {
        let repairTypeDict = res.data.map(item => ({ text: item.REPAIR_TYPE_NAME, value: item.REPAIR_TYPE_CODE + '' }));
        // this.repairTypeList = res.data;

        findFormItem(this.orderInfoFormList, 'REPAIR_TYPE_CODE').itemList = repairTypeDict;
        let tableTarget = findTableItem(this.repairLabourColumns, 'REPAIR_TYPE_CODE');
        tableTarget.dictItems = tableTarget.filterItems = repairTypeDict;
      }
    },
    // 获取收费区分
    async querySfqfDict() {
      let res = await getSfqfSelect();
      if (res.resultCode == 200) {
        let sfqfDict = res.data.map(item => ({ text: item.CHARGE_PARTITION_NAME, value: item.CHARGE_PARTITION_CODE }));
        this.sfqfDict = sfqfDict;
        let tableTargets = [
          findTableItem(this.repairLabourColumns, 'CHARGE_PARTITION_CODE'),
          findTableItem(this.repairPartColumns, 'CHARGE_PARTITION_CODE'),
          findTableItem(this.additionItemColumns, 'CHARGE_PARTITION_CODE')
        ];
        tableTargets.forEach(item => {
          item.dictItems = item.filterItems = sfqfDict;
        });
      }
    },
    // 根据工单号获取优惠模式权限
    async queryDiscountModelByRoNo(roNo) {
      let res = await queryUserControlDiscountMode1(roNo);
      if (res.resultCode == 200 && res.data && res.data.discountModeList) {
        this.discountModeList = res.data.discountModeList;
        let disCountModeDict = this.discountModeList.map(item => ({ text: item.PREFERENTIAL_TOTAL || item.DISCOUNT_MODE_NAME, value: item.DISCOUNT_MODE_CODE }));
        findFormItem(this.costInfoFormList, 'discountModeCode').itemList = disCountModeDict;
        this.calcMinDiscountFromDiscountMode(this.discountModeList);
      }
    },
    // 查询税率
    async queryTaxRate() {
      let res = await getSystemDefault({ itemCode: 1003 });
      if (res.resultCode == 200) {
        this.tax = res.data;
        findFormItem(this.costInfoFormList, 'tax').initialValue = res.data;
      }
    },
    // 查询全部人员（翻译用）
    async queryDealerUser() {
      let res = await getDealerUser();
      if (res.resultCode == 200) {
        let userDicts = res.data.map(item => ({ text: item.employeeName, value: item.userId + '' }));
        findFormItem(this.orderInfoFormList, 'SERVICE_ADVISOR').itemList = userDicts;
        findTableItem(this.repairLabourColumns, 'TECHNICIAN').dictItems = userDicts;
      }
    },

    /**
     * 弹窗相关
     */
    // 点击去零按钮
    handleSubObbBtnClick() {
      this.showSubObbPanel = true;
    },
    // 去零点击确定
    handleSubObbPanelConfimr(e) {
      let subObbFieldItem = findFormItem(this.costInfoFormList, 'subObbAmount');
      // 去零金额不等于当前去零金额时重新生成收费对象
      if (!_.isNil(e.subObbAmount) && subObbFieldItem.initialValue != e.subObbAmount) {
        subObbFieldItem.initialValue = e.subObbAmount;
        this.$nextTick(() => {
          this.updateChargeObj();
        });
      }
      this.showSubObbPanel = false;
    },

    /**
     * 页面函数
     */
    // 根据工单号查询工单详情
    async queryOrderDataByRoNo(roNo) {
      this.pageIsLoading = true;
      try {
        let res = await searchRepairOrderDetail({ roNo });
        if (res.resultCode == 200) {
          // 初始化部分数据
          res.data.labourList.forEach(item => (item.CALC_REAL_RECEIVE_AMOUNT = item.RECEIVE_AMOUNT));
          res.data.partList.forEach(item => (item.CALC_REAL_RECEIVE_AMOUNT = item.RECEIVE_AMOUNT));
          res.data.addLabourlist.forEach(item => (item.CALC_REAL_RECEIVE_AMOUNT = item.RECEIVE_AMOUNT));
          this.orderInfo = res.data;
          let targetForm = [...this.orderInfoFormList, ...this.carOwnerFormList];
          targetForm.forEach(item => {
            item.initialValue = res.data[item.fieldName] || '';
          });
          this.repairLabourTableDataSource = res.data.labourList;
          this.repairPartTableDataSource = res.data.partList;
          this.additionItemTableDataSource = res.data.addLabourlist;
          // 生成默认收费对象
          this.$nextTick(() => {
            this.updateChargeObj();
          });
        }
      } catch (err) {
        console.log(err, '查询工单详情失败');
      } finally {
        this.pageIsLoading = false;
      }
    },
    // 根绝配件销售单号查询配件销售单详情
    async querySalesPartOrderDataBySalesPartNo(salesPartNo) {
      this.pageIsLoading = true;
      try {
        let res = await searchPartRepairOrderDetail({ salesPartNo });
        if (res.resultCode == 200) {
          // 渲染页面前手动处理部分数据，不同字段及配件用于结算的部分默认数据
          res.data.OWNER_NAME = res.data.CUSTOMER_NAME;
          res.data.partlist.forEach(item => {
            item.CHARGE_PARTITION_CODE = 'Z';
            item.CALC_REAL_RECEIVE_AMOUNT = item.PART_SALES_AMOUNT * item.DISCOUNT;
            item.DISCOUNT_AMOUNT = item.PART_SALES_AMOUNT - item.PART_SALES_AMOUNT * item.DISCOUNT;
          });
          this.orderInfo = res.data;

          this.partSaleFormList.forEach(item => {
            item.initialValue = res.data[item.fieldName];
          });
          this.salesPartTableDataSource = res.data.partlist;
          this.$nextTick(() => {
            this.updateChargeObj();
          });
        }
      } catch (err) {
        console.log(err, '配件销售单详情获取失败');
      } finally {
        this.pageIsLoading = false;
      }
    },
    // 生成/更新收费对象
    updateChargeObj() {
      let receivableTableDataSource = [],
        realIncomeTableDataSource = [];
      // OEM收费对象
      if (this.judgeHasChargeObjByType('OEM')) {
        let payObj = this.calcAllAmountByType('OEM');

        receivableTableDataSource.push(this.createReceivableChargeObj(this.oemChargeObj, payObj));
        realIncomeTableDataSource.push(this.createRealIncomeChargeObj(this.oemChargeObj, payObj));
      }

      // 4s店收费对象
      if (this.judgeHasChargeObjByType('4S')) {
        let payObj = this.calcAllAmountByType('4S');
        receivableTableDataSource.push(this.createReceivableChargeObj(this.dealerChargeObj, payObj));
        realIncomeTableDataSource.push(this.createRealIncomeChargeObj(this.dealerChargeObj, payObj));
      }

      // 客户收费对象
      if (this.judgeHasChargeObjByType('OWNER')) {
        let payObj = this.calcAllAmountByType('OWNER');
        receivableTableDataSource.push(
          this.createReceivableChargeObj({ PAYMENT_OBJECT_CODE: this.orderInfo.OWNER_NO || this.orderInfo.CUSTOMER_CODE, PAYMENT_OBJECT_NAME: this.orderInfo.OWNER_NAME }, payObj)
        );
        realIncomeTableDataSource.push(
          this.createRealIncomeChargeObj({ PAYMENT_OBJECT_CODE: this.orderInfo.OWNER_NO || this.orderInfo.CUSTOMER_CODE, PAYMENT_OBJECT_NAME: this.orderInfo.OWNER_NAME }, payObj)
        );
      }

      this.receivableTableDataSource = receivableTableDataSource;
      this.realIncomeTableDataSource = realIncomeTableDataSource;
      this.calcPageReceiveAmount(realIncomeTableDataSource);
    },
    // 生成应收收费对象
    createReceivableChargeObj(ownerInfo, amountObj) {
      return {
        PAYMENT_OBJECT_CODE: ownerInfo.PAYMENT_OBJECT_CODE,
        PAYMENT_OBJECT_NAME: ownerInfo.PAYMENT_OBJECT_NAME,
        RECEIVEABLE_LABOUR_FEE: amountObj.receivableLabourAmount,
        RECEIVEABLE_REPAIR_PART_FEE: amountObj.receivablePartAmount,
        RECEIVEABLE_SALES_PART_FEE: amountObj.receivableSalesPartAmount,
        RECEIVEABLE_ADD_ITEM_FEE: amountObj.receivableAddItemAmount,
        CALC_RECEIVEABLE_TOTAL_AMOUNT: amountObj.totalReceivableAmount
      };
    },
    // 生成实收收费对象
    createRealIncomeChargeObj(ownerInfo, amountObj) {
      return {
        PAYMENT_OBJECT_CODE: ownerInfo.PAYMENT_OBJECT_CODE,
        PAYMENT_OBJECT_NAME: ownerInfo.PAYMENT_OBJECT_NAME,
        REAL_LABOUR_FEE: amountObj.realIncomeLabourAmount,
        REAL_REPAIR_PART_FEE: amountObj.realIncomePartAmount,
        REAL_SALES_PART_FEE: amountObj.realIncomeSalesPartAmount,
        REAL_ADD_ITEM_FEE: amountObj.realIncomeAddItemAmount,
        CALC_SUM_AMOUNT: amountObj.totalReceivableAmount,
        CALC_REAL_TOTAL_AMOUNT: amountObj.totalRealIncomeAmount,
        CALC_TAX_AMOUNT: amountObj.taxAmount,
        CALC_NET_AMOUNT: amountObj.noTaxAmount,
        SUB_OBB_AMOUNT: amountObj.subObbAmount,
        CALC_RECEIVABLE_AMOUNT: amountObj.roundedTotalRealIncomeAmount,
        RECEIVED_AMOUNT: 0,
        NOT_RECEIVED_AMOUNT: amountObj.roundedTotalRealIncomeAmount,
        PAY_OFF: 10041002,
        INVOICE_TAG: 10041002,
        YZ_AMOUNT: amountObj.yzAmount,
        DISCOUNT_AMOUNT: amountObj.totalDiscountAmount
      };
    },
    // 计算右侧费用信息
    calcPageReceiveAmount(payObjList) {
      let totalReceivableAmount = 0,
        totalRealIncomeAmount = 0,
        taxAmount = 0,
        noTaxAmount = 0,
        yzAmount = 0,
        totalDiscountAmount = 0,
        roundedTotalRealIncomeAmount = 0,
        claimCost = 0;
      // 计算各种类型的应收实收及优惠
      payObjList.forEach(item => {
        totalReceivableAmount += +item.CALC_SUM_AMOUNT;
        totalRealIncomeAmount += +item.REAL_LABOUR_FEE + +item.REAL_REPAIR_PART_FEE + +item.REAL_SALES_PART_FEE + +item.REAL_ADD_ITEM_FEE;
        taxAmount += +item.CALC_TAX_AMOUNT;
        noTaxAmount += +item.CALC_NET_AMOUNT;
        yzAmount += +item.YZ_AMOUNT;
        totalDiscountAmount += +item.DISCOUNT_AMOUNT;
        roundedTotalRealIncomeAmount += ['999999999999', '888888888888'].includes(item.PAYMENT_OBJECT_CODE) ? 0 : +item.CALC_RECEIVABLE_AMOUNT; // 自费总金额只计算收费区分为自费应收账款
        claimCost += item.PAYMENT_OBJECT_CODE == '999999999999' ? +item.CALC_SUM_AMOUNT : 0; // 索赔成本为所有收费区分为索赔类型项目及配件
      });

      // 渲染费用信息表单字段
      findFormItem(this.costInfoFormList, 'receiveAmount').initialValue = totalReceivableAmount;
      findFormItem(this.costInfoFormList, 'calcRealTotalAmount').initialValue = totalRealIncomeAmount;
      findFormItem(this.costInfoFormList, 'taxAmount').initialValue = taxAmount;
      findFormItem(this.costInfoFormList, 'netAmount').initialValue = noTaxAmount;
      findFormItem(this.costInfoFormList, 'yzAmaount').initialValue = yzAmount;
      findFormItem(this.costInfoFormList, 'discountAmount').initialValue = totalDiscountAmount;
      findFormItem(this.costInfoFormList, 'calcReceiveAmount').initialValue = roundedTotalRealIncomeAmount;
      findFormItem(this.costInfoFormList, 'claimCost').initialValue = claimCost;
    },
    /**
     * @description: 根据传入的列表，应收字段名及类型计算应收实收及优惠金额
     * @param {Array} list 需要计算的列表
     * @param {String} receviableField 应收字段名
     * @param {String} type 计算的收费对象类型(OEM,4S,OWNER), 不传计算全部
     * @return {Object} {receivableAmount: 应收总金额, realIncomeAmount: 实收总金额, discountAmount: 折扣金额}
     * @author: 何兴家
     */
    calcAmountInfoByListAndType(list, receviableField, type) {
      let receivableAmount = 0,
        realIncomeAmount = 0,
        discountAmount = 0,
        targetList = [];
      switch (type) {
        case 'OEM':
          targetList = list.filter(item => this.oemChargeCode.includes(item.CHARGE_PARTITION_CODE));
          break;
        case '4S':
          targetList = list.filter(item => !this.oemChargeCode.includes(item.CHARGE_PARTITION_CODE) && !this.ownerChargeCode.includes(item.CHARGE_PARTITION_CODE));
          break;
        case 'OWNER':
          targetList = list.filter(item => this.ownerChargeCode.includes(item.CHARGE_PARTITION_CODE));
          break;
        default:
          targetList = list;
      }

      targetList.forEach(item => {
        receivableAmount += +item[receviableField];
        realIncomeAmount += +item.CALC_REAL_RECEIVE_AMOUNT;
        discountAmount += +item.DISCOUNT_AMOUNT || 0;
      });

      return { receivableAmount, realIncomeAmount, discountAmount };
    },
    /**
     * @description: 根据类型计算页面金额
     * @param {String} type OEM，4S，OWNER 类型
     * @return {Object} 计算后的全部金额
     * @author: 何兴家
     */
    calcAllAmountByType(type) {
      let discountCouponAmount = 0; // 优惠券总使用金额
      let subObbAmount = type == 'OWNER' ? findFormItem(this.costInfoFormList, 'subObbAmount').initialValue || 0 : 0; // 去零金额,仅计算到用户收费对象上

      let { receivableAmount: receivableLabourAmount, realIncomeAmount: realIncomeLabourAmount, discountAmount: labourDiscountAmount } = this.calcAmountInfoByListAndType(
        this.syncRepairLabourTableDataList,
        'LABOUR_AMOUNT',
        type || ''
      );
      let { receivableAmount: receivablePartAmount, realIncomeAmount: realIncomePartAmount, discountAmount: partDiscountAmount } = this.calcAmountInfoByListAndType(
        this.syncRepairPartTableDataList,
        'PART_SALES_AMOUNT',
        type || ''
      );
      let { receivableAmount: receivableAddItemAmount, realIncomeAmount: realIncomeAddItemAmount, discountAmount: addItemDiscountAmount } = this.calcAmountInfoByListAndType(
        this.syncAdditionItemTableDataList,
        'ADD_ITEM_AMOUNT',
        type || ''
      );
      let { receivableAmount: receivableSalesPartAmount, realIncomeAmount: realIncomeSalesPartAmount, discountAmount: salesPartDiscountAmount } = this.calcAmountInfoByListAndType(
        this.syncSalesPartTableDataList,
        'PART_SALES_AMOUNT',
        type || ''
      );

      this.syncDiscountCouponTableDataList.forEach(item => {}); // 优惠券未完成 hxj 2021-1-7

      // 实收应收优惠汇总
      let totalReceivableAmount = receivableLabourAmount + receivablePartAmount + receivableAddItemAmount + receivableSalesPartAmount;
      let totalRealIncomeAmount = realIncomeLabourAmount + realIncomePartAmount + realIncomeAddItemAmount + realIncomeSalesPartAmount;
      let totalDiscountAmount = labourDiscountAmount + partDiscountAmount + addItemDiscountAmount + salesPartDiscountAmount;
      if (type == 'OWNER') totalRealIncomeAmount = totalRealIncomeAmount - discountCouponAmount - subObbAmount; // 优惠券及去零只针对用户收费对象

      // 计算税额及不含税金额
      let taxAmount = totalRealIncomeAmount * (this.tax || 0.13);
      let noTaxAmount = totalRealIncomeAmount - taxAmount;

      // 元整实收今天
      let roundedTotalRealIncomeAmount = setRound(totalRealIncomeAmount);
      let yzAmount = totalRealIncomeAmount - roundedTotalRealIncomeAmount;

      return {
        receivableLabourAmount,
        receivablePartAmount,
        receivableAddItemAmount,
        receivableSalesPartAmount,
        realIncomeLabourAmount,
        realIncomePartAmount,
        realIncomeAddItemAmount,
        realIncomeSalesPartAmount,
        totalDiscountAmount,
        totalReceivableAmount,
        totalRealIncomeAmount,
        taxAmount,
        noTaxAmount,
        roundedTotalRealIncomeAmount,
        subObbAmount,
        yzAmount
      };
    },
    /**
     * @description: 根据类型判断是否存在对应收费对象
     * @param {String} type OEM 4S OWNER
     * @return {Boolean}
     * @author: 何兴家
     */
    judgeHasChargeObjByType(type) {
      let targetCodeList = null;
      switch (type) {
        case 'OEM':
          targetCodeList = this.oemChargeCode;
          break;
        case '4S':
          targetCodeList = [...this.oemChargeCode, ...this.ownerChargeCode];
          break;
        case 'OWNER':
          targetCodeList = this.ownerChargeCode;
          break;
      }

      return !!(
        this.syncRepairLabourTableDataList.find(item => (type == '4S' ? !targetCodeList.includes(item.CHARGE_PARTITION_CODE) : targetCodeList.includes(item.CHARGE_PARTITION_CODE))) ||
        this.syncRepairPartTableDataList.find(item => (type == '4S' ? !targetCodeList.includes(item.CHARGE_PARTITION_CODE) : targetCodeList.includes(item.CHARGE_PARTITION_CODE))) ||
        this.syncAdditionItemTableDataList.find(item => (type == '4S' ? !targetCodeList.includes(item.CHARGE_PARTITION_CODE) : targetCodeList.includes(item.CHARGE_PARTITION_CODE))) ||
        this.syncSalesPartTableDataList.find(item => (type == '4S' ? !targetCodeList.includes(item.CHARGE_PARTITION_CODE) : targetCodeList.includes(item.CHARGE_PARTITION_CODE)))
      );
    },
    // 详情tab页切换
    handleDetailTabChange(e) {
      switch (e) {
        case '维修项目':
          findFormItem(this.discountFormList, 'DISCOUNT').initialValue = this.discourtHistoryList[0];
          break;
        case '维修材料':
          findFormItem(this.discountFormList, 'DISCOUNT').initialValue = this.discourtHistoryList[1];
          break;
        case '附加项目':
          findFormItem(this.discountFormList, 'DISCOUNT').initialValue = this.discourtHistoryList[2];
          break;
        case '销售材料':
          findFormItem(this.discountFormList, 'DISCOUNT').initialValue = this.discourtHistoryList[3];
          break;
      }
    },
    // 折扣率回车事件
    handleDiscountEnter(val) {
      console.log(val, this.activeDetailTab);
      if (val > 1 || val < 0) return;
      switch (this.activeDetailTab) {
        case '维修项目':
          if (val < this.discountLimt.LABOUR_AMOUNT_DISCOUNT) return notifyAction(`折扣不能小于维修项目最低折扣权限${this.discountLimt.LABOUR_AMOUNT_DISCOUNT}`, 'warning');
          if (!this.selectedRepairLabourList.length) return notifyAction('请选择需要打折的项目', 'warning');
          this.calcTableReceiveAmoutnByDiscount(val, this.selectedRepairLabourList, 'LABOUR_AMOUNT');
          this.discourtHistoryList[0] = val;
          break;
        case '维修材料':
          if (val < this.discountLimt.REPAIR_PART_DISCOUNT) return notifyAction(`折扣不能小于维修配件最低折扣权限${this.discountLimt.REPAIR_PART_DISCOUNT}`, 'warning');
          if (!this.selectedRepairPartList.length) return notifyAction('请选择需要打折的配件', 'warning');
          this.calcTableReceiveAmoutnByDiscount(val, this.selectedRepairPartList, 'PART_SALES_AMOUNT');
          this.discourtHistoryList[1] = val;
          break;
        case '附加项目':
          if (val < this.discountLimt.ADDITIONAL_ITEMS_DISCOUNT) return notifyAction(`折扣不能小于附加项目最低折扣权限${this.discountLimt.ADDITIONAL_ITEMS_DISCOUNT}`, 'warning');
          if (!this.selectedAdditionItemList.length) return notifyAction('请选择需要打折的项目', 'warning');
          this.calcTableReceiveAmoutnByDiscount(val, this.selectedAdditionItemList, 'ADD_ITEM_AMOUNT');
          this.discourtHistoryList[2] = val;
          break;
        case '销售材料':
          if (val < this.discountLimt.SALES_PART_DISCOUNT) return notifyAction(`折扣不能小于配件销售最低折扣权限${this.discountLimt.SALES_PART_DISCOUNT}`, 'warning');
          if (!this.selectedSalesPartList.length) return notifyAction('请选择需要打折的配件', 'warning');
          this.calcTableReceiveAmoutnByDiscount(val, this.selectedSalesPartList, 'PART_SALES_AMOUNT');
          this.discourtHistoryList[3] = val;
          break;
      }
    },
    // 优惠模式改变事件
    handleDiscountModeChange(val) {
      console.log(val);
      let discountTarget = this.discountModeList.find(item => item.DISCOUNT_MODE_CODE == val);

      // 根据优惠模式中的折扣进行打折，优惠模式清空的话折扣率重置为1
      this.syncRepairLabourTableDataList.length &&
        this.calcTableReceiveAmoutnByDiscount(discountTarget ? discountTarget.LABOUR_AMOUNT_DISCOUNT : 1, this.syncRepairLabourTableDataList, 'LABOUR_AMOUNT');

      this.syncRepairPartTableDataList.length && this.calcTableReceiveAmoutnByDiscount(discountTarget ? discountTarget.REPAIR_PART_DISCOUNT : 1, this.syncRepairPartTableDataList, 'PART_SALES_AMOUNT');

      this.syncAdditionItemTableDataList.length &&
        this.calcTableReceiveAmoutnByDiscount(discountTarget ? discountTarget.ADDITIONAL_ITEMS_DISCOUNT : 1, this.syncAdditionItemTableDataList, 'ADD_ITEM_AMOUNT');

      this.syncSalesPartTableDataList.length && this.calcTableReceiveAmoutnByDiscount(discountTarget ? discountTarget.SALES_PART_DISCOUNT : 1, this.syncSalesPartTableDataList, 'PART_SALES_AMOUNT');
    },
    // 过滤优惠模式中各项优惠最小值
    calcMinDiscountFromDiscountMode(modeList) {
      let obj = {
        REPAIR_PART_DISCOUNT: 1,
        LABOUR_AMOUNT_DISCOUNT: 1,
        ADDITIONAL_ITEMS_DISCOUNT: 1,
        SALES_PART_DISCOUNT: 1
      };
      let calcObj = modeList.reduce((t, v) => {
        t.REPAIR_PART_DISCOUNT = v.REPAIR_PART_DISCOUNT < t.REPAIR_PART_DISCOUNT ? v.REPAIR_PART_DISCOUNT : t.REPAIR_PART_DISCOUNT;
        t.LABOUR_AMOUNT_DISCOUNT = v.LABOUR_AMOUNT_DISCOUNT < t.LABOUR_AMOUNT_DISCOUNT ? v.LABOUR_AMOUNT_DISCOUNT : t.LABOUR_AMOUNT_DISCOUNT;
        t.ADDITIONAL_ITEMS_DISCOUNT = v.ADDITIONAL_ITEMS_DISCOUNT < t.ADDITIONAL_ITEMS_DISCOUNT ? v.ADDITIONAL_ITEMS_DISCOUNT : t.ADDITIONAL_ITEMS_DISCOUNT;
        t.SALES_PART_DISCOUNT = v.SALES_PART_DISCOUNT < t.SALES_PART_DISCOUNT ? v.SALES_PART_DISCOUNT : t.SALES_PART_DISCOUNT;
        return t;
      }, obj);

      // console.log(calcObj, 'hexj001');
      this.discountLimt = calcObj;
    },
    /**
     * @description: 根据传入的折扣及列表给项目或者配件打折
     * @param {Number} discount 折扣
     * @param {Array} lists 需要打折的列表
     * @param {String} receiveableAmountField 列表中的应收字段
     * @author: 何兴家
     */
    calcTableReceiveAmoutnByDiscount(discount, lists, receiveableAmountField) {
      lists.forEach(item => {
        if (this.rechargeableCodes.includes(item.CHARGE_PARTITION_CODE)) {
          item.DISCOUNT = discount;
          item.CALC_REAL_RECEIVE_AMOUNT = item[receiveableAmountField] * item.DISCOUNT;
          item.DISCOUNT_AMOUNT = item[receiveableAmountField] - item.CALC_REAL_RECEIVE_AMOUNT;
        }
      });
      this.$nextTick(() => {
        lists.length && this.updateChargeObj();
      });
    },
    /**
     * @description: 根据传入的列表及应收字段生成行项的收费对象数据
     * @param {Array} list 需要生成的列表
     * @param {String} receivableField 应收字段
     * @return {Array} 生成的收费对象
     * @author: 何兴家
     */
    createRowChargeObjList(list, receivableField) {
      let chargeObjList = list.map((item, index) => {
        let paymentObj = {};
        if (this.oemChargeCode.includes(item.CHARGE_PARTITION_CODE)) {
          paymentObj = this.oemChargeObj;
        } else if (this.ownerChargeCode.includes(item.CHARGE_PARTITION_CODE)) {
          paymentObj = { PAYMENT_OBJECT_CODE: this.orderInfo.OWNER_NO, PAYMENT_OBJECT_NAME: this.orderInfo.OWNER_NAME };
        } else {
          paymentObj = this.dealerChargeObj;
        }

        return {
          LINE: index,
          ...paymentObj,
          RECEIVEABLE_AMOUNT: item[receivableField] || 0,
          REAL_RECEIVE_AMOUNT: item.CALC_REAL_RECEIVE_AMOUNT || 0,
          DISCOUNT_AMOUNT: item.DIS_LABOUR_AMOUNT || 0,
          DISCOUNT: item.DISCOUNT
        };
      });
      return chargeObjList;
    },
    // 拼接页面数据
    async getPageData() {
      let orderFormData = this.$refs.orderInfoForm ? await this.$refs.orderInfoForm.GET_FORM_DATA() : [false, {}];
      let balanceFormData = await this.$refs.balanceForm.GET_FORM_DATA();
      let costInfoFormData = await this.$refs.costInfoForm.GET_FORM_DATA();
      let salesPartInfo = this.$refs.partSaleForm ? await this.$refs.partSaleForm.GET_FORM_DATA() : [false, {}];

      if (orderFormData[0] || balanceFormData[0] || costInfoFormData[0] || salesPartInfo[0]) return;
      let toHumoDataObj = _.cloneDeep({ ...orderFormData[1], ...balanceFormData[1], ...salesPartInfo[1] }); // 转小写
      jsonToHump(toHumoDataObj);
      let formDataObj = { ...toHumoDataObj, ...costInfoFormData[1] };
      // 将空串处理为null防止后端报错
      Object.keys(formDataObj).forEach(item => {
        formDataObj[item] = formDataObj[item] === '' ? null : formDataObj[item];
      });

      // 重新计算应收实收
      let labourAmount = 0,
        repairPartAmount = 0,
        addItemAmount = 0,
        salesPartAmount = 0;
      this.syncReceivableTableDataList.forEach(item => {
        labourAmount += +item.RECEIVEABLE_LABOUR_FEE;
        addItemAmount += +item.RECEIVEABLE_ADD_ITEM_FEE;
      });
      this.syncRealIncomeTableDataList.forEach(item => {
        repairPartAmount += +item.REAL_REPAIR_PART_FEE;
        salesPartAmount += +item.REAL_SALES_PART_FEE;
      });

      let requestObj = {
        ...formDataObj,

        // 手动处理部分数据(接收字段与前端定义不统一)
        // roNo: '', //工单号
        // salesPartNo: '', // 配件销售单号
        orderType: this.orderType == 'repair' ? 1 : 2, // 单据类型（1：工单 2：备件销售）

        labourAmount, // 应收工时费
        repairPartAmount, // 维修材料实收
        addItemAmount, // 附加项目应收
        salesPartAmount, // 配件销售实收

        allAmount: formDataObj.calcReceiveAmount, // 合计金额(旧为元整后的实收金额当前应与现金收款相等)
        arrearsAmount: formDataObj.arrBalance == 1 ? formDataObj.calcReceiveAmount : 0, // 欠收金额
        guarantor: '', // 担保方(暂无)
        taxAmountBalance: formDataObj.taxAmount, // 税额
        netAmountBalance: formDataObj.netAmount, // 不含税金额
        giftAmount: 0, // 优惠券使用金额(暂定)
        vin: findFormItem(this.carOwnerFormList, 'VIN').initialValue, // 车辆vin
        payOff: 10041002, // PAY_OFF  是否结清
        discountModeName: formDataObj.discountModeCode ? this.discountModeList.find(item => item.DISCOUNT_MODE_CODE == formDataObj.discountModeCode).DISCOUNT_MODE_NAME : '', // 收费区分名称(部分厂端功能使用)

        // claimCost: '', // 索赔成本
        // receiveAmount: '', // 应收总金额
        // calcRealTotalAmount: '', // 实收金额
        // calcReceiveAmount: '', // 现金收款
        // discountModeCode: '', // 优惠模式代码
        // payTypeCode: '', // 付款方式
        // arrBalance: '', // 是否欠款结算 1/0
        // tax: '', // 税率
        // discountAmount: '', // 合计优惠金额
        // delivererHobbyContact: '', // 希望联系方式
        // traceTime: '', // 希望联系时间
        // remarkdetail: '', // 备注
        // serviceAdvisor: '', // 服务顾问

        bLDtoList: this.syncRepairLabourTableDataList, // 结算单维修项目明细及收费对象
        hiddenList1: this.createRowChargeObjList(this.syncRepairLabourTableDataList, 'LABOUR_AMOUNT'),
        bRPDtoList: this.syncRepairPartTableDataList, // 结算单维修材料明细及收费对象
        hiddenList2: this.createRowChargeObjList(this.syncRepairPartTableDataList, 'PART_SALES_AMOUNT'),
        bSPDtoList: this.syncSalesPartTableDataList, // 结算单销售材料明细及收费对象
        hiddenList3: this.createRowChargeObjList(this.syncSalesPartTableDataList, 'PART_SALES_AMOUNT'),
        bAIDtoList: this.syncAdditionItemTableDataList, // 结算单附加项目明细及收费对象
        hiddenList4: this.createRowChargeObjList(this.syncAdditionItemTableDataList, 'ADD_ITEM_AMOUNT'),
        receivedList: this.syncRealIncomeTableDataList, // 实收收费对象
        receivableList: this.syncReceivableTableDataList // 应收收费对象
      };
      return requestObj;
    },
    // 点击结算按钮
    async handleBallanceClick() {
      try {
        let submitData = await this.getPageData();
        let res = await saveBalanceAccounts(submitData);
        if (res.resultCode == 200) {
          findFormItem(this.ballanceFormList, 'BALANCE_NO').initialValue = res.data;
          this.pageType = 'detail';
          notifyAction('结算成功', 'success');
          this.$emit('refeshTable');
        }
      } catch (err) {
        console.error(err);
      }
    },

    // 点击取消/关闭
    handleCancel() {
      this.$emit('close');
    }
  }
};
</script>

<style lang="less" scoped>
.box {
  border: 1px solid #ccc;
  padding-top: @modulePadding;
  padding-right: @modulePadding;
  padding-left: @modulePadding;
  border-radius: @borderRadius;
  margin-bottom: 15px;
  box-shadow: @boxShadow;
}
.topBtnsWrap {
  display: flex;
  justify-content: space-between;
}
.detailWrap {
  position: relative;
  .left {
    position: absolute;
    left: 0;
    width: calc(100% - 310px);
    border: 1px solid @borderColor;
    border-radius: @borderRadius;
    box-shadow: @boxShadow;
    padding: @modulePadding;
  }
  .right {
    margin-left: calc(100% - 280px);
    border: 1px solid @borderColor;
    border-radius: @borderRadius;
    box-shadow: @boxShadow;
    padding: @modulePadding;
  }
}
.titleWrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
